package com.bwie.controller;

import com.bwie.common.pojo.GroupBuyingActivityProducts;
import com.bwie.common.result.Result;
import com.bwie.service.GroupBuyingLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class GroupBuyingLController {
    @Autowired
    private GroupBuyingLService groupBuyingLService;

    //拼团商品列表
    @GetMapping("/groupBuyingList")
    public Result<List<GroupBuyingActivityProducts>> groupBuyingList() {
        List<GroupBuyingActivityProducts> list = groupBuyingLService.groupBuyingList();
        return Result.success(list);
    }

    //拼团商品添加
    @PostMapping("/groupBuyingAdd")
    public Result groupBuyingAdd(@RequestBody GroupBuyingActivityProducts groupBuyingActivityProducts) {
        groupBuyingLService.groupBuyingAdd(groupBuyingActivityProducts);
        return Result.success();
    }

    //拼团商品删除
    @DeleteMapping("/groupBuyingDel/{groupBuyingActivityProductId}")
    public Result groupBuyingDel(@PathVariable Long groupBuyingActivityProductId) {
        groupBuyingLService.groupBuyingDel(groupBuyingActivityProductId);
        return Result.success();
    }

    //拼团商品修改
    @PutMapping("/groupBuyingUpdate")
    public Result groupBuyingUpdate(@RequestBody GroupBuyingActivityProducts groupBuyingActivityProducts) {
        groupBuyingLService.groupBuyingUpdate(groupBuyingActivityProducts);
        return Result.success();
    }

}
